#!/bin/sh
echo "This utility will remove certain config files."
SIM_MANDOMAIN=$1
MYFILE=$2
. /etc/sipman.conf

echo "Options: SIM_MANDOMAIN=$SIM_MANDOMAIN, FILE=$MYFILE."
case $MYFILE in
  (config-date)    DIR=$SIM_IPDATAB
                   FILE=snmpinfodate.txt
                   ;;
  (dhcp-name)      DIR=$SIM_IPDATAB
                   FILE=dhcpname.txt
                   ;;
  (nodetype)	   DIR=$SIM_IPDATAB
                   FILE=nodetype.txt
                   ;;
  (*)              echo "Usage: $0 <domain> parameter
                         config-date this will trigger the update (import-snmp) process for all nodes.
                         dhcp-name   this will remove all dhcp names (which will be rediscovered over time
                                     by the read-dhcp process), affecting dynamic prefix dns names.
                         nodetype    this will trigger a rediscover of the nodetype
                         !!!! This utility will have an impact on the Sipman process, be sure you know what
                              you are doing. This tool is mainly meaned for testing and implementation purposes."
                   exit
                   ;;
esac
echo "Will start removing files $FILE from $DIR in a few secconds...."
sleep 10
find $DIR -name $FILE | while read FFILE
do
  echo "Removing file $FFILE."
  rm $FFILE
done
